import {
    createRouter,
    createWebHistory
} from 'vue-router';

// 登录注册页面框架与搜索
import Login from '../components/login.vue';
import Register from '../components/register.vue';
import Home from '../components/home.vue';
import SearchPage from '../components/SearchPage.vue';

// 用户页面
import HomeContent from '../components/HomeContent.vue';
import Contact from '../components/Contact.vue';
import User from '../components/User.vue';
import ShoppingCart from '../components/ShoppingCart.vue';
import ProductDetail from '../components/ProductDetail.vue';
import EditUserInfo from '../components/EditUserInfo.vue';
import OrderHistory from '../components/OrderHistory.vue';

// 管理员页面
import ProductManagement from '../components/ProductManagement.vue';
import OrderManagement from '../components/OrderManagement.vue';
import SalesReport from '../components/SalesReport.vue';
import CustomerManagement from '../components/CustomerManagement.vue';

//支付页面
import Success from '../components/Success.vue';
import Error from '../components/Error.vue'

const routes = [{
        path: '/login',
        name: 'Login',
        component: Login,
    },
    {
        path: '/register',
        name: 'Register',
        component: Register,
    },
    {
        path: '/',
        component: Home,
        children: [{
                path: '',
                name: 'HomeContent',
                component: HomeContent
            },
            {
                path: 'cart',
                name: 'ShoppingCart',
                component: ShoppingCart
            },
            {
                path: 'user',
                name: 'User',
                component: User
            },
            {
                path: 'contact',
                name: 'Contact',
                component: Contact
            },
            {
                path: 'edit-user-info',
                name: 'EditUserInfo',
                component: EditUserInfo
            },
            {
                path: 'order-history',
                name: 'OrderHistory',
                component: OrderHistory
            },
            {
                path: '/product-management', // 商品管理
                name: 'ProductManagement',
                component: ProductManagement
            }, {
                path: '/order-management', // 订单管理
                name: 'OrderManagement',
                component: OrderManagement
            }, {
                path: '/sales-report', // 销售统计
                name: 'SalesReport',
                component: SalesReport
            }, {
                path: '/customer-management', // 客户管理
                name: 'CustomerManagement',
                component: CustomerManagement
            },
            {
                path: '/search',
                name: 'SearchPage',
                component: SearchPage
            }
        ]
    },
    {
        path: '/product', // 商品详情
        name: 'ProductDetail',
        component: ProductDetail
    },
    {
        path: '/success',
        name: 'Success',
        component: Success
    }, {
        path: '/error',
        name: 'Error',
        component: Error
    }
];

const router = createRouter({
    history: createWebHistory(),
    routes,
});

export default router;